//
//  MainToolbarCategory.m
//
//  Created by Matthew Hutton on 31/07/2007.
//
//  This file is part of D&D Manager
//
//D&D Manager, a D&D Character and battle management program.
//Copyright (C) 2007, Matthew Hutton
//
//This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License along with this program; if not, write to:
//The Free Software Foundation, Inc.,
//51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

#import "MainToolbarCategory.h"


@implementation MyDocument(MainToolbarCategory)
- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar
	 itemForItemIdentifier:(NSString *)itemIdentifier
 willBeInsertedIntoToolbar:(BOOL)flag{
	NSToolbarItem *item = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
	//configuring custom items.
	if([itemIdentifier isEqualToString:@"BattleTB"]){
		[item setLabel:@"Battle"];
		[item setImage:[NSImage imageNamed:@"BattleTB.png"]];
		[item setPaletteLabel:[item label]];
		[item setTarget:appController];
		[item setAction:@selector(selectBattleTab)];
    }else if([itemIdentifier isEqualToString:@"CharacterTB"]){
		[item setLabel:@"Character"];
		[item setPaletteLabel:[item label]];
		[item setTarget:appController];
		[item setAction:@selector(selectCharacterTab)];
    }else if([itemIdentifier isEqualToString:@"CharacterTesterTB"]){
		[item setLabel:@"Tester"];
		[item setPaletteLabel:[item label]];
		[item setTarget:appController];
		[item setAction:@selector(selectCharacterTesterTab)];
	}else if([itemIdentifier isEqualToString:@"ClassesTB"]){
		[item setLabel:@"Classes"];
		[item setPaletteLabel:[item label]];
		[item setTarget:appController];
		[item setAction:@selector(displayEditCharacterClassesSheet:)];
	}else if([itemIdentifier isEqualToString:@"FeatsTB"]){
		[item setLabel:@"Feats and Abilities"];
		[item setPaletteLabel:[item label]];
		[item setTarget:appController];
		[item setAction:@selector(selectFeatsTab)];
	/*}else if([itemIdentifier isEqualToString:@"SpecialAbilTB"]){
		[item setLabel:@"Special Abilities"];
		[item setPaletteLabel:[item label]];
		[item setTarget:appController];
		[item setAction:@selector(selectSpecialAbilitiesTab)];*/
	}else if([itemIdentifier isEqualToString:@"SkillsTB"]){
		[item setLabel:@"Skills"];
		[item setPaletteLabel:[item label]];
		[item setTarget:appController];
		[item setAction:@selector(showSuperskillSheet:)];
    }else if([itemIdentifier isEqualToString:@"SpellsTB"]){
		[item setLabel:@"Spells"];
		[item setPaletteLabel:[item label]];
		[item setTarget:appController];
		[item setAction:@selector(selectSpellsTab)];
	}else if([itemIdentifier isEqualToString:@"WeaponsTB"]){
		[item setLabel:@"Weapons"];
		[item setPaletteLabel:[item label]];
		[item setTarget:appController];
		[item setAction:@selector(displayWeaponsSheet:)];
	}else if([itemIdentifier isEqualToString:@"DMNotesTB"]){
		[item setLabel:@"DM Notes"];
		[item setPaletteLabel:[item label]];
		[item setTarget:appController];
		[item setAction:@selector(selectDMNotesTab)];
	}else if([itemIdentifier isEqualToString:@"DiceRollTB"]){
		[item setLabel:@"Roll Dice"];
		[item setPaletteLabel:[item label]];
		[item setTarget:appController];
		[item setAction:@selector(displayRollDiceSheet:)];
	}else if([itemIdentifier isEqualToString:@"GrantXPTB"]){
		[item setLabel:@"Grant XP"];
		[item setPaletteLabel:[item label]];
		[item setTarget:appController];
		[item setAction:@selector(displayGrantXPsheet:)];
	}else if([itemIdentifier isEqualToString:@"ImportTB"]){
		[item setLabel:@"Import"];
		[item setPaletteLabel:[item label]];
		[item setTarget:self];
		[item setAction:@selector(importCharactersFromOtherFiles:)];
	}else if([itemIdentifier isEqualToString:@"RestTB"]){
		[item setLabel:@"Rest"];
		[item setPaletteLabel:[item label]];
		[item setTarget:appController];
		[item setAction:@selector(loadRestScreen:)];
	}else if([itemIdentifier isEqualToString:@"FileOptionsTB"]){
		[item setLabel:@"File Options"];
		[item setPaletteLabel:[item label]];
		[item setTarget:appController];
		[item setAction:@selector(showFilePreferences:)];
	}
    return [item autorelease];
}

- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar*)toolbar{
	return [NSArray arrayWithObjects:NSToolbarSeparatorItemIdentifier, NSToolbarSpaceItemIdentifier, NSToolbarFlexibleSpaceItemIdentifier, NSToolbarCustomizeToolbarItemIdentifier, @"BattleTB", @"CharacterTB", @"CharacterTesterTB",/* @"SpecialAbilTB",*/  @"SpellsTB", @"DMNotesTB", @"ClassesTB", @"SkillsTB", @"FeatsTB", @"WeaponsTB", @"DiceRollTB", @"GrantXPTB", @"ImportTB", @"RestTB", @"FileOptionsTB", nil];
}

- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar*)toolbar{
	return [NSArray arrayWithObjects:@"CharacterTB", @"ClassesTB", @"FeatsTB", @"SkillsTB",/* @"SpecialAbilTB",*/ @"SpellsTB", @"WeaponsTB", NSToolbarSpaceItemIdentifier, @"BattleTB", @"DMNotesTB",@"CharacterTesterTB", NSToolbarSeparatorItemIdentifier, @"DiceRollTB", @"GrantXPTB", @"ImportTB", @"RestTB", @"FileOptionsTB",
		NSToolbarCustomizeToolbarItemIdentifier, nil];
}
- (NSArray *)toolbarSelectableItemIdentifiers:(NSToolbar *)toolbar{
	return [NSArray arrayWithObjects:@"CharacterTB",@"SpellsTB",@"BattleTB",@"DMNotesTB",@"CharacterTesterTB",/* @"SpecialAbilTB",*/ @"FeatsTB"/*, @"SkillsTB"*/, @"ClassesTB", @"WeaponsTB", nil];
}
- (BOOL)validateToolbarItem:(NSToolbarItem *)theItem{
	//NSString *identifier=[theItem itemIdentifier];
	return YES;
}
@end
